package com.huangliusong.web.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * 通知
 * @author huangliusong
 * @since 2018/10/2
 * {@link }
 */
@ControllerAdvice(assignableTypes =HelloWorldController.class)
public class HelloWorldControllerAdvice {

    @ModelAttribute("message")
    public String getMes(){
        return "hls ";
    }


    @ModelAttribute("lang")
    public String getHeader(@RequestHeader("Accept-Language") String lang){
        return lang;
    }

    @ModelAttribute("JSESSIONID")
    public String getJSESSIONID(@CookieValue(value = "JSESSIONID",required = false) String JSESSIONID){
        return JSESSIONID;
    }

    @ExceptionHandler(Throwable.class)
    public ResponseEntity<String> onException(Throwable throwable){
        return ResponseEntity.ok(throwable.getMessage());
    }
}
